<template lang="">
  <div class="content">
    <button @click="ContentStore.add()">获取一条数据</button>
    <ul>
      <!-- <li type="1" v-for="(item, index) of list" :key="item.id">{{item.title}}</li> -->
      <li type="1" v-for="(item, index) of ContentStore.list" :key="item.id">{{item.title}}</li>
    </ul>
  </div>
</template>
<script setup lang="ts" name="Content">
  import { useContentStore } from '@/store/content'
  // 数据
  let ContentStore = useContentStore();

  // 方法
  // 订阅变化 参数1  mutation 本次修改信息 ，state 修改的数据
  ContentStore.$subscribe((mutation, state) => {
    console.log(`mutation里面->`, mutation, "state 里面->", state)
    localStorage.setItem('list', JSON.stringify(state.list))
  });

</script>
<style scoped>
  .content {
    background: orangered;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 0 10px;
    width: 900px;
    padding: 10px 30px;
    text-align: center;
  }

  button {
    height: 50px;
    background-color: rgb(98, 131, 180);
    color: white;
    font-size: 30px;
  }

  ul {
    width: 90%;
    text-align: left;
    font-size: 20px;
    line-height: 50px;
    font-family: '宋体';
    font-weight: 900;
    background-color: greenyellow;
  }

  li {
    margin: 3px 0px;
    padding-left: 15px;
    background-color: white;
  }
</style>